package com.xhh.nphm.web.controller.system;

import com.xhh.nphm.common.core.controller.BaseController;
import com.xhh.nphm.common.core.domain.AjaxResult;
import com.xhh.nphm.system.service.MWorkcsbaseService;
import com.xhh.nphm.system.service.MmailWorkFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Objects;

@RestController
@RequestMapping("/system/mMailWF")
public class MmailWorkFormController extends BaseController {

    @Autowired
    private MmailWorkFormService mMailWorkFormService;

    @Autowired
    private MWorkcsbaseService mWorkcsbaseService;

    /**
     * 根据id 进行多选删除 和单个删除
     * @param ids
     * @return
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String... ids) {
        return toAjax(mMailWorkFormService.removeByIds(Arrays.asList(ids)));
    }

    /**
     * 抄送件
     * 将工单抄送到指定部门
     * @param wfId 工单编号
     * @param deptNos 部门编号集
     * @return 响应结果
     */
    @PostMapping("/copy")
    public AjaxResult copy(Integer wfId,String deptNos,String deptNames){
        if (Objects.equals(deptNames, "")){
            return AjaxResult.success();
        }
        return toAjax(mWorkcsbaseService.copy(wfId,deptNos,deptNames));
    }

}
